import { expect } from 'chai';

import {
    isObject,
    isString,
    isArray,
    isUndef,
    isFunction,
    isDate,
    isNumber,
    isBoolean,
    isRegExp,
    isEmptyObject
} from '../index';


describe('数据类型判断模块', () => {
    const emptyObj = {};
    const str = 'abc';
    const arr = [];
    var undef;
    function fn() {};
    const date = new Date();
    const num = 123;
    const bool = true;
    const obj = { foo: 'bar'}
    const reg = /\d{3}/ ;

    it('isObject is OK', () => {
        expect(isObject(str)).to.false;
        expect(isObject(emptyObj)).to.true;
        expect(isObject(obj)).to.true;
    });
    it('isString is OK', () => {
        expect(isString(str)).to.true;
        expect(isString(bool)).to.false;
    });
    it('isArray is OK', () => {
        expect(isArray(arr)).to.true;
        expect(isArray(obj)).to.false;
    });
    it('isUndef is OK', () => {
        expect(isUndef(str)).to.false;
        expect(isUndef(undef)).to.true;
    });
    it('isFunction is OK', () => {
        expect(isFunction(undef)).to.false;
        expect(isFunction(fn)).to.true;
    });
    it('isDate is OK', () => {
        expect(isDate(num)).to.false;
        expect(isDate(date)).to.true;
    });
    it('isNumber is OK', () => {
        expect(isNumber(str)).to.false;
        expect(isNumber(num)).to.true;
    });
    it('isBoolean is OK', () => {
        expect(isBoolean(bool)).to.true;
        expect(isBoolean(num)).to.false;
    });
    it('isRegExp is OK', () => {
        expect(isRegExp(str)).to.false;
        expect(isRegExp(reg)).to.true;
    });
    it('isEmptyObject is OK', () => {
        expect(isEmptyObject(emptyObj)).to.true;
        expect(isEmptyObject(obj)).to.false;
        expect(isEmptyObject(arr)).to.false;
    })

})

